/*
**  P76
*/

#include <stdio.h>
#include <stdlib.h>

/*   more than 1   */
void movetow ( int num, char from, char using, char to );
/*    only 1   */
void send ( int num, char from, char to );

int main () {
    int total = 4;
    scanf("%d",&total);
    movetow(total,'A','B','C');
    return 0;
}


void movetow ( int num, char from, char using, char to ) {
    if ( num < 1 ) {
        printf("err num\n");
        exit(-3);
    } else if ( num > 2 ) {
        movetow(num-1,from,to,using);
        send(num,from,to);
        movetow(num-1,using,from,to);
    } else if ( num == 2 ) {
        send(1,from,using);
        send(2,from,to);
        send(1,using,to);
    } else if ( num == 1 ) {
        send(1,from,to);
    }
}

void send ( int num, char from, char to ) {
    printf("%d\t%c->%c\n",num,from,to);
}